package export.magicWeapon
{
	import base.BaseAddEffect;
	import base.BaseBitmapDataClip;
	import base.BaseBitmapDataPool;
	import base.BaseHero;
	import base.BaseMagicWeapon;
	
	import com.game.data.vo.EquipmentVO;
	import com.greensock.TweenMax;
	
	import export.bullet.SpecialEffectBullet;
	
	import flash.geom.Point;
	
	public class MagicBagua extends BaseMagicWeapon
	{
		
		public function MagicBagua(bo:BaseHero)
		{
			super(bo);
			this.mp = 10;
		}
		
		override protected function initBBDC():void
		{
			var body:* = null;
			var bmdArray:Array = BaseBitmapDataPool.getBitmapDataArrayByName("MagicBaguaBmd");
			if (bmdArray)
			{
				body = {
					"name"  : "body",
					"source": bmdArray
				};
				bbdc = new BaseBitmapDataClip([body], 50, 50, new Point(0, 0));
				bbdc.setOffsetXY(1, -10);
				bbdc.setFrameStopCount([[10], [9999]]);
				bbdc.setFrameCount([1, 1]);
				bbdc.setAddScriptWhenFrameOver(scriptFrameOverFunc);
				this.addChild(bbdc);
				return;
			}
			throw new Error("MagicBagua--BitmapData Error!");
		}
		
		override public function useSkill():void
		{
			var equip:EquipmentVO = this.sourceRole.getPlayer().getCurEquipByType("zbfb");
			if (equip)
			{
				if (equip.getLevel() >= 6)
				{
					super.useSkill();
				}
			}
		}
		
		override public function showSkill():void
		{
			var mon:* = undefined;
			var b:SpecialEffectBullet = null;
			var parentIdx:int = 0;
			var time:int = 0;
			var mons:Array = null;
			var equip:EquipmentVO = this.sourceRole.getPlayer().getCurEquipByType("zbfb");
			if (equip)
			{
				if (equip.getLevel() >= 6)
				{
					b = new SpecialEffectBullet("baguaEffect");
					b.x = this.sourceRole.x;
					b.y = this.sourceRole.y + 40;
					b.setOwner(this.sourceRole);
					b.setDirect(0);
					b.setDisable();
					b.setAction("hit1");
					parentIdx = gc.gameScene.getChildIndex(this.sourceRole);
					if (parentIdx != -1)
					{
						gc.gameScene.addChildAt(b, parentIdx);
					}
					this.sourceRole.magicBulletArray.push(b);
					time = 25 * (equip.getLevel() / 2);
					if (equip.getFiveElementString().indexOf("木") != -1)
					{
						time *= 2;
					}
					mons = gc.pWorld.getMonsterArray();
					for each (mon in mons)
					{
						if (!mon.isInvincible() && !mon.isDead())
						{
							mon.addCurAddEffect([{
								"name": BaseAddEffect.STUN,
								"time": time
							}]);
						}
					}
					TweenMax.delayedCall(20, function (_self:MagicBagua):*
					{
						_self.setAction("idle");
					}, [this]);
				}
			}
		}
	}
}
